package com.cslc.mp.service;

import static org.junit.Assert.*;

import java.io.File;

import net.sf.json.JSONObject;

import org.junit.Ignore;
import org.junit.Test;

import com.cslc.mp.constant.MpInfo;

/**
 * service测试，各个接口的单元测试
 * @author kll
 *
 */
public class ServiceTest {
	
	/**
	 * 获取永久素材总数测试
	 */
	@Ignore
	public void testMaterialCountGet() {
		JSONObject jsonObject = null;
		jsonObject = CoreServiceFactory.getInstance().materialCountGet();
		if(jsonObject.containsKey("image_count")) {
			int imageCount = jsonObject.getInt("image_count");
			assertEquals(0, imageCount);
		}
		else 
			fail("获取素材总数时出现错误");
	}
	
	/**
	 * 获取临时素材测试
	 */
	@Test
	public void testTempMaterialGet() {
		JSONObject jsonObject = null;
		String mediaId = "wWs84L9r-EQvXPyTskRZU8ibqS7tPrJ6jPAcP3PSnn6ItPEonrbElaRnHo-3ysFx";
		CoreServiceFactory.getInstance().tempMaterialGet(mediaId);
		File file = new File(MpInfo.IMG_PATH + "\\" + mediaId + ".jpg");
		assertTrue(file.exists());
	}
}